A Tour of Go
Packages
Imports / Export
Functions
名前付き戻り値
code:go
func split(sum int) (x, y int) {
x = sum * 4 / 9
y = sum - x
return // 一見戻り値なしに見えるので、この行は短い関数で使う
}
Variables
Basic Types
Constants
For
If
式を伴うIf
code:go
func pow(x, n, lim float64) float64 {
if v := math.Pow(x, n); v < lim {
return v
} else {
fmt.Printf("%g >= %g\n", v, lim)
}
// can't use v here, though / vはここでは使えない(スコープ外)
return lim
}
Switch
Defer
Pointers
Structs
Arrays
Slices
Range
Maps
Function values
Methods
Receivers
Interfaces
Stringers
Errors
Readers
Images
Goroutines
Channels
Range and Close
Select
sync.Mutex